﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<%@include file="../../commons/meta.jsp"%>
<c:set var="baseUrl" value="${ctx}api/university/" scope="request"/>
<link rel="stylesheet" href="${ctx}assets/plugins/pure/pure-min.css" media="all" />
<script type="text/javascript" src="${ctx}assets/plugins/plupload/2.2.1/js/plupload.full.min.js"></script>
<script type="text/javascript" src="${ctx}assets/plugins/plupload/2.2.1/js/i18n/zh_CN.js"></script>
</head>
<body>
    <%@include file="../../commons/head.jsp"%>
    <div class="content">
        <%@include file="../../commons/menu.jsp"%>
        <!--右侧展示部分-->
        <div class="right-zq">
            <div class="dynamic">
                <form id="listForm" action="${ctx}api/university/" method="post">
                    <div class="role dynamiclayer" style="display: block;">
                        <div class="title orange2">
                            <span class="left">高校信息管理</span><label> > </label><span>学校信息管理</span>
                        </div>
                        <div class="role-input role-input2 role-input3">
                            <ul class="input">
                                <li class="p33">学校层次：
                                    <select name="searchMap.level,eq,int" class="input1 num" style="text-align: center;">
                                        <option value="">全部</option>
                                        <option value="1">本科</option>
                                        <option value="2">专科</option>
                                    </select>
                                </li>
                                <li class="p33">类型：
                                    <select id="type" name="searchMap.type,like,string" class="input1" 
                                        style="text-align: center;" onchange="getMajorClass()">
                                        <option value="">全部</option>
                                        <option value="综合">综合</option>
                                        <option value="理工">理工</option>
                                        <option value="财经">财经</option>
                                        <option value="农林">农林</option>
                                        <option value="医药">医药</option>
                                        <option value="师范">师范</option>
                                        <option value="体育">体育</option>
                                        <option value="政法">政法</option>
                                        <option value="艺术">艺术</option>
                                        <option value="民族">民族</option>
                                        <option value="军事">军事</option>
                                        <option value="语言">语言</option>
                                        <option value="其他">其他</option>
                                    </select>
                                </li>
                            </ul>
                            <ul class="input">
                                <li class="p33">学校代码：<input id="code" type="text" name="searchMap.code,like,string" value="" class="input1 num" maxlength="6" /></li>
                                <li class="p33">名称：<input type="text" name="searchMap.name,like,string" value="" class="input1" maxlength="36" /></li>
                            </ul>
                            <div class="button">
                                <span class="orange2" onclick="listFormPageSearch(1)">查询</span>
                                <s:authorize access="hasAuthority('college:add')">
                                    <span class="orange2"><a href="${ctx}api/university/add">添加</a></span>
                                </s:authorize>
                                <s:authorize access="hasAuthority('college:import')">
                                    <span class="orange2"><a href="${baseUrl}import">导入</a></span>
                                </s:authorize>
                            </div>
                        </div>
                        <div class="role-table role-table2">
                            <table cellspacing="0px" id="datatable">
                            </table>
                        </div>
                        <div class="role-page">
                            <input type="hidden" id="pageSize" name="pageSize" value="10" />
                            <ul id="datapagefoot">
                            </ul>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
<script type="text/javascript">
var defaultPageFoot = '';
defaultPageFoot += '<li><a class="first orange2-text" id="firstPage" href="javascript:void(0);">首页</a></li>';
// <li><a class="next orange-text orange-border" id="pagesNextPage"
 // href="javascript:void(0);"><fmt:message key="member.nextPage"/></a></li>
defaultPageFoot += '<li>共<label class="num"  id="pagesPageCount">0</label>页，每页<label class="num">10</label>条，';
defaultPageFoot += '到第<input type="text" id="pageNumers" name="pageNumber" value="1" maxlength="9" onpaste="return false;" class="num" />页';
defaultPageFoot += '<span class="confirm orange2-text orange2-border"  onclick="listFormPageSearch(1)">确定</span></li>';

/** 分页查询 */
function listFormPageSearch(pageNum) {
  if(isNaN($("#code").val())){
    alertError('学校代码，请输入数字！');
    return false;
  }
  
 var pageForm = $("#listForm").serializeObject();
 var pageCounts = $("#pageCounts").val();
 checkPageNumber(pageForm, pageNum);

 var searchMap = [];
 $.each(pageForm, function (name, value) {
  if (name.indexOf('searchMap') >= 0) {
   var searchMapMeta = {};
   delete pageForm[name];
   var name2 = name.replace("searchMap.", "");
   searchMapMeta[name2] = value;
   searchMap.push(name2 + "," + value);
  }
 });
 pageForm.searchList = searchMap;
 // 默认按id排序
 pageForm.sort = "id";
 var searchJsonUrl = 'api/university/page.json';
 var pageData = JSON.stringify(pageForm);
 debugs("ajax pageData : " + pageData);
 var tableHead = ['学校代码','名称', '校徽', '简称','性质','创办时间','类型', '校训', '现任领导', '地址', '操作'];
 var tableHtml = getHead(tableHead);
 $.ajax({
  url: searchJsonUrl + "?rand=" + Math.random(),
  data: pageData,
  type: 'POST',
  contentType: "application/json",
  dataType: 'json',
  success: function (pages) {
   var tr = "";
   $.each(pages.rows, function (index, item) {
    var trtmp = getValueTr([filtUndef(item.code),
     filtUndef(item.name),
     '<img src="' + item.logoUrl + '" alt="'+ item.enName +'" style="width: 100px">',
     filtUndef(item.shortName),
     filtUndef(item.classify),
     filtUndef(item.creation),
     filtUndef(item.type),
     filtUndef(item.motto),
     filtUndef(item.leader),
     filtUndef(item.address),
     <s:authorize access="hasAuthority('college:update')">
     '<a href="javascript:void(0);" onclick="mod(' + item.id + ')">修改</a>&nbsp;&nbsp;' +
     </s:authorize>
     <s:authorize access="hasAuthority('college:delete')">
     '<a href="javascript:void(0);" onclick="del(' + item.id + ')">删除</a>' +
     </s:authorize>
     '']);
    tr += trtmp;
   });
   if (isEmpty(tr)) {
    tr = "<tr><td colspan='" + tableHead.length + "' class='error'><fmt:message key='Temporarily.no.data'/></td></tr>";
   }

   $("#datatable").html(tableHtml + tr);
   $("#pageSize").val(pages.pageSize);
   $("#datapagefoot").html(getPageFoot(pages));
   // 解决当上次查询无数据时，弹出 “请输入合理的页码范围!”提示
   if ($("#pageCounts").val() == "0") {
    $("#pageCounts").val("");
   }
  }, error: function (xhr) {
   alertError("<fmt:message key='sys.message.searcherror'/>");// 请求失败遇到异常触发
   $("#datapagefoot").html(getDefaultPageFoot());
  }
 });
}

 // 初始化时加载分页数据。
 listFormPageSearch(1);
</script>
<%@include file="../../commons/footpop.jsp"%>
</body>
</html>
